#ifndef  __ESEAL_MGN_H__
#define  __ESEAL_MGN_H__


typedef struct _eseal_data
{
    INT8U   eSealDataLth;
    INT16U  eSealDataType;
    INT8U*  peSealData;
    struct _eseal_data* pNextData;
}ESEAL_DATA;


typedef struct _eseal_detail
{
  INT8U   VendorID[FRAME_DATA_LTH_VENDORID];
  INT8U   eSealID[FRAME_DATA_LTH_ESEALID];
  INT16U  eSealStatus;
  INT8S   DynamicRSSI;
  INT8U   TTL;
  ESEAL_DATA* pDataHeader;

  struct  _eseal_detail* pNext;
}ESEAL_DETAIL;


void   eSealManage_Init(void);
/*
INT8U  eSealTable_Free_eSealObj(INT8U* peSealID , INT8U* pVendorID);
INT8U  eSealTable_Add_eSealObj(INT8U* peSealID , INT8U* pVendorID , INT16U eSealStatus, INT8S Rssi);
INT8U  eSealTable_Update_eSealObj(INT8U* peSealID , INT8U* pVendorID , INT16U eSealStatus, INT8S Rssi);
INT8U  eSealTable_Check_eSealTTL(void);

ESEAL_DETAIL*  eSealTable_Get_eSealObj(void);
ESEAL_DETAIL*  eSealTable_Find_eSealObj(INT8U* peSealID , INT8U* pVendorID);
ESEAL_DETAIL*  eSealTable_Get_MaxTTLeSeal(void);
*/

BOOL eSeal_Check_eSealObjID(INT8U* peSealID , INT8U* pVendorID);
void eSeal_New_eSealObj(INT8U* peSealID , INT8U* pVendorID , INT16U eSealStatus, INT8S Rssi);
void eSeal_Del_eSealObj(ESEAL_DETAIL* peSeal);
void eSeal_Update_eSealObj(ESEAL_DETAIL* peSeal , INT16U eSealStatus, INT8S Rssi);
ESEAL_DETAIL* eSeal_Get_eSealObj(void);

void   eSealData_Del_AllDataObj(ESEAL_DETAIL* peSeal);
void   eSealDataTable_Read_TypeData(ESEAL_DATA* pDsteSealData , ESEAL_DATA* pScreSealData);
INT8U  eSealDataTable_Add_DataObj(ESEAL_DETAIL* peSeal , INT16U DataType, INT8U DataLth, INT8U* pData);
INT8U  eSealDataTable_Get_OneDataObj(ESEAL_DETAIL* peSeal , ESEAL_DATA* peSealData);
INT8U  eSealDataTable_Del_TypeData(ESEAL_DETAIL* peSeal , ESEAL_DATA* peSealData);
ESEAL_DATA*  eSealDataTable_Del_OneDataObj(ESEAL_DETAIL* peSeal);
ESEAL_DATA*  eSealDataTable_Find_TypeData(ESEAL_DETAIL* peSeal , INT16U  DataType);
void  eSealDataTable_Update_DataObj(ESEAL_DATA* peSealData , INT8U DataLth, INT8U* pData);



#define  GET_ESEAL_DATA_TYPE(__cmd , __type)            (INT16U)(((INT16U)(__cmd)<<8)|__type)
#define  GET_ESEAL_CMD(__datatype)                      (INT8U)((__datatype&0xff00)>>8)
#define  GET_ESEAL_OPTION(__datatype)                   (INT8U)(__datatype&0x00ff)

#define  ESEAL_TABLE_NO_ERR              (0x00)
#define  ESEAL_TABLE_ERR_FULL            (0x01)
#define  ESEAL_TABLE_ERR_NOT_FIND        (0x02)
#define  ESEAL_TABLE_ERR_ESEAL_EXIST     (0x03)

#define  ESEAL_TABLE_ERR                 (0xff)

#define  ESEAL_DATATABLE_NO_ERR          (0x00)
#define  ESEAL_DATATABLE_ERR_TYPE        (0x01)
#define  ESEAL_DATATABLE_ERR_NOT_FIND    (0x02)
#define  ESEAL_DATATABLE_ERR             (0xff)

#define  ESEAL_TABLE_SIZE                (10)
#define  ESEAL_DATA_TABLE_SIZE           (20)
#define  ESEAL_TIME_TTL_UNIT             (1000)

#endif

